<?php

namespace App\Http\Requests\Admin;

use App\Http\Controllers\Admin\AdminAuthController;
use App\Http\Requests\ApiRequest;
use Illuminate\Validation\Rule;

/**
 * @property string password
 * @property string account
 * @property string type
 * @property string lang
 * @property string|null debug - 前端打开 console 写入 window.DEBUG = 'token'
 */
class LoginPostRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'account'  => 'required|string|max:'.self::MAX_STRING,
            'password' => 'required|string|min:6|max:'.self::MAX_STRING,
            'type'     => ['required', 'string', Rule::in([
                AdminAuthController::LOGIN_TYPE_PANX,
                AdminAuthController::LOGIN_TYPE_CUSTOMER,
                AdminAuthController::LOGIN_TYPE_STORE,
            ])],
        ];
    }

    /**
     * @return array
     */
//    public function messages()
//    {
//        return [
//            'account.*'  => '登录名称必须是字符串',
//            'password.*' => '登录密码必须是字符串',
//            'type.*'     => '登录的后台类型必须填写',
//        ];
//    }
}
